// NonDBVariable.cpp: implementation of the NonDBVariable class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "NonDBVariable.h"
#include "PropertyVisitor.h"
#include "PropertyExPression.h"
#include "PropertyOwner.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
namespace pa
{
	NonDBVariable::NonDBVariable()
	{

	}

	NonDBVariable::~NonDBVariable()
	{

	}

	Property* NonDBVariable::Clone()
	{
		NonDBVariable *pVariable = new NonDBVariable;
		ASSERT(pVariable);

		this->CopyPropertyData(*pVariable,*this);

		return pVariable;
	}


	BOOL NonDBVariable::Accept(PropertyVisitor& visitor)
	{
		return visitor.Visit(this);
	}


	void NonDBVariable::InitValue()
	{
		if(GetOwner() == NULL || this->Default().IsEmpty() 
							  || m_bIsInitState)
		{
			return;
		}

		m_bIsInitState = TRUE;
		PropertyExpression expr(this->Default(), 
			this->GetOwner()->GetPropertyContainer());

		*static_cast<Variable*>(this) = (StdString)expr.Caculate();
		m_bIsInitState = FALSE;
	}

};